﻿using Autofac;
using Autofac.Builder;
using Autofac.Features.Scanning;
using System;
using System.Reflection;

namespace Inovout.Component
{
    public static class RegistrationExtensions
    {
        public static IRegistrationBuilder<object, ScanningActivatorData, DynamicRegistrationStyle>
            RegisterComponents(this ContainerBuilder builder, params Assembly[] domainAssemblies)
        {
            return builder.RegisterAssemblyTypes(domainAssemblies)
                .Where(t => t.IsDefined(typeof(ComponentAttribute)))
                .AsImplementedInterfaces()
                .AsSelf();
        }
    }
}
